<script>
$(function() {
	$( ".datepick" ).datepicker({
								 minDate: new Date(),
								 changeMonth: true,
								changeYear: true,
								dateFormat: "dd-mm-yy",
								buttonImage:$('#root').val()+"img/calendar.jpg"
	 							});
});
function addrow()
{
	$(".tbchithi tr:last").clone(true).insertAfter(".tbchithi tr:last");
	}
$(document).ready(function () {          
    $(".btthem").click(function() {
        addrow();
        $(".tbchithi tr:last input").val("");
        $(".tbchithi tr:last input:first").focus();
           // $("table.tbchithi tr:last").after('<tr><td>Row 4</td></tr>');
            //return false;
    });
});
</script>
<div id="tabs">
	<ul>
        <li id="current">
        <li><?php 
              if(empty($idnhanvien))   
                    echo $this->Html->link(__('Ds công việc', true), array('action' => 'index',$kehoach)); 
             else
                    echo $this->Html->link(__('Ds công việc', true), array('action' => 'index',$kehoach,$idnhanvien));   ?></li>
	</li>
        </li>
		
	</ul>
</div>
<div class="nvchithis">
	<h2><?php 
	echo $form->input('root',array('id'=>'root','type'=>'hidden','value'=>$this->webroot));
            echo $kh['Donvi']['tendv'].'<br></h2>';
            echo '<h5>Các công việc theo nội dung công văn, chỉ thị</h5>';	
	
            echo '<h4>'.$kh['Thoigian']['tentg'];
            echo ' : '.date('d-m-y',strtotime($kh['Thoigian']['ngaybd'])).' <b>Đến</b> '.date('d-m-y',strtotime($kh['Thoigian']['ngaykt'])).'</h4>';
    ?>
  
	<table cellpadding="0" cellspacing="0" class="tbchithi" id="tables">
	<tr>
				<th><?php echo 'STT';?></th>
		
			<th><?php echo 'Người thực hiện';?></th>
            <th><?php echo 'Nội dung công việc';?></th>
			
			<th><?php echo 'Đơn vị tính';?></th>
            <th><?php echo 'KQ cần đạt';?></th>
            <th><?php echo 'Ngày giao';?></th>
			<th><?php echo 'Hạn hoàn thành';?></th>
			<th><?php echo 'KQ thực hiện';?></th>
		
			<th class="actions"><?php __('Lựa chọn');?></th>
	</tr>
	<?php
	$i = 0;
	foreach ($nvchithis as $nvchithi):
		$class = null;
		if ($i++ % 2 == 0) {
			$class = ' class="altrow"';
		}
	?>
	<tr<?php echo $class;?>>
		<td><?php echo $i;//echo $nvchithi['Nvchithi']['id']; ?>&nbsp;</td>
	
		<td>
			<?php echo $nvchithi['Nhanvien']['tennv']; ?>
		</td>
	
		<td><?php echo $nvchithi['Nvchithi']['congviec']; ?>&nbsp;</td>
        	<td>
			<?php echo $nvchithi['Dvt']['donvitinh']; ?>
		</td>
		<td><?php echo $nvchithi['Nvchithi']['ketqua']; ?>&nbsp;</td>
		<td><?php echo $nvchithi['Nvchithi']['thoihan']; ?>&nbsp;</td>
		<td><?php echo $nvchithi['Nvchithi']['danhgia']; ?>&nbsp;</td>
		<td class="actions">
			<?php //echo $this->Html->link(__('View', true), array('action' => 'view', $nvchithi['Nvchithi']['id'])); ?>
			<?php 
                if($nvchithi['Nvchithi']['danhgia']==1)
                    echo $this->Html->link(__('Cập nhật', true), array('action' => 'editnv', $nvchithi['Nvchithi']['id'],$kehoach,$idnhanvien)); ?>
			
		</td>
	</tr>
<?php endforeach; ?>

<?php 
    echo $this->Form->create('Nvchithi',array('url'=>'editnv/'.$this->Form->value('Nvchithi.id').'/'.$kehoach.'/'.$idnhanvien));
?>
    <tr>
    <td><?php //echo $i+1;?></td>
    <?php 
    echo $this->Form->input('id');
    echo $this->Form->hidden('kehoach_id',array('value'=>$kehoach)); ?>
    <td><?php //echo $nvchithi['Nhanvien']['tennv'];//echo $this->Form->input('nhanvien_id',array('label'=>false));
       echo $this->Form->input('nhanvien_id',array('label'=>false,'readonly'=>'readonly')); 
     ?></td>
    <td><?php 
        //echo $nvchithi['Nvchithi']['congviec'];
        echo $this->Form->input('congviec',array('label'=>false,'readonly'=>'readonly')); 
       
    ?></td>
    <td><?php
          echo $nvchithi['Dvt']['donvitinh']; 
           echo $this->Form->hidden('dvt_id'); 
     ?></td>
    
     <td><?php echo $this->Form->input('ketqua',array('label'=>false,'readonly'=>'readonly'));?></td>
    
    
     <td><?php echo $this->Form->input('ngaygiao',array('type'=>'text',
                    'label'=>false,'readonly'=>true));?></td>
    
   
   <td><?php 
        //if(empty($idnhanvien))
//            echo $this->Form->input('thoihan',array('type'=>'text','label'=>false,'class'=>'datepick'));
//        else 
//            echo $this->Form->input('thoihan',array('readonly'=>'readonly','type'=>'text','label'=>false));
     //   echo $nvchithi['Nvchithi']['thoihan'];
           echo $this->Form->input('thoihan',array('label'=>false,'readonly'=>'readonly','type'=>'text')); 
     
     ?></td>
    <td><?php echo $this->Form->input('danhgia',array('label'=>false));?></td>
    
   	 <td> <?php echo $this->Form->end(__('Lưu', true));?></td>
  </tr>
  	</table> 
    
	<p>
	<?php
	echo $this->Paginator->counter(array(
	'format' => __('Trang %page%/%pages%, hiện có %count% công việc theo kế hoạch', true)
	));
	?>	</p>

	<div class="paging">
		<?php echo $this->Paginator->prev('<< ' . __('previous', true), array(), null, array('class'=>'disabled'));?>
	 | 	<?php echo $this->Paginator->numbers();?>
 |
		<?php echo $this->Paginator->next(__('next', true) . ' >>', array(), null, array('class' => 'disabled'));?>
	</div>
</div>
